<script setup>
import { useIsCollapseStore } from '@/stores/isCollapse'

// 获取isCollapseStore中的actions
const { toggleCollapse } = useIsCollapseStore()

// 获取用户头像url
const getUserAvatar = name => {
  return new URL(`../assets/images/${name}.png`, import.meta.url).href
}
</script>

<template>
  <div class="header">
    <div class="left">
      <component is="menu" class="icons" @click="toggleCollapse"></component>
      <el-breadcrumb separator="/" class="breadcrumb">
        <el-breadcrumb-item :to="{ path: '/' }"> 首页 </el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <div class="right">
      <el-dropdown>
        <span class="el-dropdown-link">
          <img :src="getUserAvatar('user')" alt="" />
        </span>
        <template #dropdown>
          <el-dropdown-menu>
            <el-dropdown-item>个人中心</el-dropdown-item>
            <el-dropdown-item>退出登录</el-dropdown-item>
          </el-dropdown-menu>
        </template>
      </el-dropdown>
    </div>
  </div>
</template>

<style scoped lang="less">
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 100%;
  .left {
    display: flex;
    align-items: center;
    color: #fff;

    .icons {
      width: 18px;
      height: 18px;
      margin-right: 10px;
      cursor: pointer;
    }
    :deep(.breadcrumb) span {
      font-size: 14px;
      color: #fff;
      cursor: pointer;
    }
  }
  .right {
    img {
      width: 40px;
      height: 40px;
      border-radius: 50%;
    }
  }
}
</style>
